import axios from "axios";

import interceptors from "./interceptors";

axios.defaults.baseURL = import.meta.env.VITE_BASE_URL;
axios.defaults.timeout = 30000;
axios.defaults.headers["Content-Type"] = "application/json;charset=utf-8";

interceptors.forEach(({ requestResolve, responseResolve, responseError }) => {
  if (requestResolve) axios.interceptors.request.use(requestResolve);
  if (responseResolve)
    axios.interceptors.response.use(responseResolve, responseError);
});

export default axios;
